package 剑指offer;

public class Offer44_JZ {
    public static int findNthDigit(int n) {
        int count = 0;
        for(int i=0; i<Integer.MAX_VALUE; i++) {
            String s = String.valueOf(i);
            count += s.length();
            if(count-1 == n) {
                return s.charAt(s.length()-1) - '0';
            } else if (count-1 > n) {
                return s.charAt(n-count+s.length()) - '0';
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println(findNthDigit(1000000000));
    }
}
